package webapp;

import java.util.ArrayList;
import java.util.List;

import mda.type.ApplicationBaseType;
import mda.type.IDtoType;
import mda.type.IEntityType;
import mda.type.IServiceType;
import flca.mda.codegen.data.ITemplate;
import flca.mda.codegen.data.Template;
import flca.mda.codegen.data.TemplateMergeStrategy;

public class JavaConstants implements TemplatesConstBase {
	
	public static final String CARTRIDGE_NAME = "webapp-backend";

	protected static final String Backend = LE + WebappConstants.BACKEND + RI;

	public Tid[] getTemplates() {
		return new Tid[] { Tid.ENTITY, Tid.ENTITY_VALIDATOR, Tid.ENTITY_MOCK, Tid.ENTITY_MERGER, Tid.ENTITY_DAO,
				Tid.ENTITY_DAO_IMPL, Tid.ENTITY_DAO_TEST, Tid.ENTITY_DAO_MOCK, 
				Tid.ENTITY_SEARCH_DTO,
				Tid.DTO,
				Tid.JSONARRAY,

				Tid.SERVICE,
				Tid.SERVICE_TEST, Tid.SERVICE_INTF, Tid.SERVICE_IMPL, Tid.SERVICE_EXT_RPC, Tid.SERVICE_EXT_REST, Tid.SERVICE_JSON_MOCKS,

				Tid.APP_GUICE_MODULE, Tid.APP_GUICE_BINDER, Tid.APP_CONFIG_PROVIDERS, Tid.APP_CONSTANTS, Tid.APP_BOOTSTRAPPER,
				Tid.APP_STARTUP_SERVLET, Tid.APP_CONFIG, Tid.APP_CONTEXT, Tid.APP_TABLES_TOOL,
				Tid.APP_EXT_SERVICE_BASE, Tid.APP_TEST_SERVICE_BASE, Tid.APP_TEST_DAO_BASE, Tid.APP_DBS_PROVIDER,
				Tid.APP_TEST_STARTUP, Tid.APP_README, Tid.APP_PERSISTENCE_XML, 
				Tid.APP_SERVER, Tid.APP_JETTY_LAUNCHER, Tid.APP_JETTY_SERVLETCONFIG};
	}

	private static List<ITemplate> allTemplates;

	public JavaConstants() {
		super();
		if (allTemplates == null) {
			allTemplates = makeTemplates();
		}
	}

	@Override
	public List<ITemplate> getAllTemplates() {
		return allTemplates;
	}
	
	public List<ITemplate> makeTemplates() {
		List<ITemplate> result = new ArrayList<ITemplate>();
		
		result.add(makeTemplate_ENTITY());
		result.add(makeTemplate_ENTITY_VALIDATOR());
		result.add(makeTemplate_ENTITY_MOCK());
		result.add(makeTemplate_ENTITY_MERGER());
		result.add(makeTemplate_ENTITY_DAO());
		result.add(makeTemplate_ENTITY_DAO_IMPL());
		result.add(makeTemplate_ENTITY_DAO_TEST());
		result.add(makeTemplate_ENTITY_DAO_MOCK());
		result.add(makeTemplate_ENTITY_SEARCH_DTO());
		result.add(makeTemplate_DTO());
		result.add(makeTemplate_JSONARRAY());
		result.add(makeTemplate_SERVICE());
		result.add(makeTemplate_SERVICE_TEST());
		result.add(makeTemplate_SERVICE_INTF());
		result.add(makeTemplate_SERVICE_IMPL());
		result.add(makeTemplate_SERVICE_EXT_RPC());
		result.add(makeTemplate_SERVICE_EXT_REST());
		result.add(makeTemplate_SERVICE_JSON_MOCKS());
		result.add(makeTemplate_APP_GUICE_MODULE());
		result.add(makeTemplate_APP_GUICE_BINDER());
		result.add(makeTemplate_APP_CONFIG_PROVIDERS());
		result.add(makeTemplate_APP_CONSTANTS());
		result.add(makeTemplate_APP_BOOTSTRAPPER());
		result.add(makeTemplate_APP_STARTUP_SERVLET());
		result.add(makeTemplate_APP_CONFIG());
		result.add(makeTemplate_APP_CONTEXT());
		result.add(makeTemplate_APP_TABLES_TOOL());
		result.add(makeTemplate_APP_EXT_SERVICE_BASE());
		result.add(makeTemplate_APP_TEST_SERVICE_BASE());
		result.add(makeTemplate_APP_TEST_DAO_BASE());
		result.add(makeTemplate_APP_DBS_PROVIDER());
		result.add(makeTemplate_APP_TEST_STARTUP());
		result.add(makeTemplate_APP_README());
		result.add(makeTemplate_APP_PERSISTENCE_XML());
		result.add(makeTemplate_APP_SERVER());
		result.add(makeTemplate_APP_JETTY_LAUNCHER());
		result.add(makeTemplate_APP_JETTY_SERVLETCONFIG());
				
		return result;
	}
	
	private ITemplate makeTemplate_ENTITY() {
		Template r = new Template();
		r.setName(Tid.ENTITY.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("<%=CLASSNAME%>");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.Entity.class.getName());
		r.setJetPath("/backend/Entity.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_VALIDATOR() {
		Template r = new Template();
		r.setName(Tid.ENTITY_VALIDATOR.name());
		r.setPackage("<%=PACKAGE%>.util");
		r.setClassname("<%=CLASSNAME%>Validator");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.EntityValidator.class.getName());
		r.setJetPath("/backend/EntityValidator.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,IDtoType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_MOCK() {
		Template r = new Template();
		r.setName(Tid.ENTITY_MOCK.name());
		r.setPackage("<%=PACKAGE%>.util");
		r.setClassname("<%=CLASSNAME%>Mock");
		r.setTargetDir("<%=Backend%>/<%=src-gen-test%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.EntityMock.class.getName());
		r.setJetPath("/backend/EntityMock.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,IDtoType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_MERGER() {
		Template r = new Template();
		r.setName(Tid.ENTITY_MERGER.name());
		r.setPackage("<%=PACKAGE%>.util");
		r.setClassname("<%=CLASSNAME%>Merger");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.EntityMerger.class.getName());
		r.setJetPath("/backend/EntityMerger.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_DAO() {
		Template r = new Template();
		r.setName(Tid.ENTITY_DAO.name());
		r.setPackage("<%=PACKAGE%>.dao");
		r.setClassname("<%=CLASSNAME%>Dao");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.EntityDao.class.getName());
		r.setJetPath("/backend/EntityDao.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_DAO_IMPL() {
		Template r = new Template();
		r.setName(Tid.ENTITY_DAO_IMPL.name());
		r.setPackage("<%=PACKAGE%>.dao");
		r.setClassname("<%=CLASSNAME%>DaoImpl");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.EntityDaoImpl.class.getName());
		r.setJetPath("/backend/EntityDaoImpl.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_DAO_TEST() {
		Template r = new Template();
		r.setName(Tid.ENTITY_DAO_TEST.name());
		r.setPackage("<%=PACKAGE%>.dao");
		r.setClassname("Test<%=CLASSNAME%>Dao");
		r.setTargetDir("<%=Backend%>/<%=src-gen-test%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.TestEntityDao.class.getName());
		r.setJetPath("/backend/TestEntityDao.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_DAO_MOCK() {
		Template r = new Template();
		r.setName(Tid.ENTITY_DAO_MOCK.name());
		r.setPackage("<%=PACKAGE%>.dao");
		r.setClassname("<%=CLASSNAME%>DaoMock");
		r.setTargetDir("<%=Backend%>/<%=src-gen-test%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.EntityDaoMock.class.getName());
		r.setJetPath("/backend/EntityDaoMock.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_ENTITY_SEARCH_DTO() {
		Template r = new Template();
		r.setName(Tid.ENTITY_SEARCH_DTO.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("Search<%=CLASSNAME%>Dto");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.SearchDto.class.getName());
		r.setJetPath("/backend/SearchDto.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IEntityType.class,IDtoType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_DTO() {
		Template r = new Template();
		r.setName(Tid.DTO.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("<%=CLASSNAME%>");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.Dto.class.getName());
		r.setJetPath("/backend/Dto.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IDtoType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_JSONARRAY() {
		Template r = new Template();
		r.setName(Tid.JSONARRAY.name());
		r.setPackage("<%=PACKAGE%>.util");
		r.setClassname("<%=CLASSNAME%>JsonArray");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.JsonArray.class.getName());
		r.setJetPath("/backend/JsonArray.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(null);
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_SERVICE() {
		Template r = new Template();
		r.setName(Tid.SERVICE.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("<%=CLASSNAME%>");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.Service.class.getName());
		r.setJetPath("/backend/Service.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_SERVICE_TEST() {
		Template r = new Template();
		r.setName(Tid.SERVICE_TEST.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("Test<%=CLASSNAME%>");
		r.setTargetDir("<%=Backend%>/<%=src-gen-test%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.TestService.class.getName());
		r.setJetPath("/backend/TestService.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_SERVICE_JSON_MOCKS() {
		Template r = new Template();
		r.setName(Tid.SERVICE_JSON_MOCKS.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("<%=CLASSNAME%>JsonMockGenerator");
		r.setTargetDir("<%=Backend%>/<%=src-gen-test%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.ServiceJsonMocks.class.getName());
		r.setJetPath("/backend/ServiceJsonMocks.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(5);
		return r;
	}


	private ITemplate makeTemplate_SERVICE_INTF() {
		Template r = new Template();
		r.setName(Tid.SERVICE_INTF.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("<%=CLASSNAME%>Intf");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.ServiceIntf.class.getName());
		r.setJetPath("/backend/ServiceIntf.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_SERVICE_IMPL() {
		Template r = new Template();
		r.setName(Tid.SERVICE_IMPL.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("<%=CLASSNAME%>Impl");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.ServiceImpl.class.getName());
		r.setJetPath("/backend/ServiceImpl.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_SERVICE_EXT_RPC() {
		Template r = new Template();
		r.setName(Tid.SERVICE_EXT_RPC.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("Rpc<%=CLASSNAME%>");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.RpcService.class.getName());
		r.setJetPath("/backend/RpcServiceImpl.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_SERVICE_EXT_REST() {
		Template r = new Template();
		r.setName(Tid.SERVICE_EXT_REST.name());
		r.setPackage("<%=PACKAGE%>");
		r.setClassname("Rest<%=CLASSNAME%>");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.RestService.class.getName());
		r.setJetPath("/backend/RestServiceImpl.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(5);
		return r;
	}

	private ITemplate makeTemplate_APP_GUICE_MODULE() {
		Template r = new Template();
		r.setName(Tid.APP_GUICE_MODULE.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>Module");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppGuiceModule.class.getName());
		r.setJetPath("/backend-appbase/AppGuiceModule.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(null);
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_GUICE_BINDER() {
		Template r = new Template();
		r.setName(Tid.APP_GUICE_BINDER.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>Binder");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppGuiceBinder.class.getName());
		r.setJetPath("/backend-appbase/AppGuiceBinder.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(null);
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_CONFIG_PROVIDERS() {
		Template r = new Template();
		r.setName(Tid.APP_CONFIG_PROVIDERS.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>ConfigProviders");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppConfigProviders.class.getName());
		r.setJetPath("/backend-appbase/AppConfigProviders.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_CONSTANTS() {
		Template r = new Template();
		r.setName(Tid.APP_CONSTANTS.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>Constants");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppConstants.class.getName());
		r.setJetPath("/backend-appbase/AppConstants.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_BOOTSTRAPPER() {
		Template r = new Template();
		r.setName(Tid.APP_BOOTSTRAPPER.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>Bootstrapper");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppBootstrapper.class.getName());
		r.setJetPath("/backend-appbase/AppBootstrapper.jet");
		r.setMergeStrategy(TemplateMergeStrategy.SKIP);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_STARTUP_SERVLET() {
		Template r = new Template();
		r.setName(Tid.APP_STARTUP_SERVLET.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>StartupServlet");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppStartupServlet.class.getName());
		r.setJetPath("/backend-appbase/AppStartupServlet.jet");
		r.setMergeStrategy(TemplateMergeStrategy.SKIP);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(null);
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_CONFIG() {
		Template r = new Template();
		r.setName(Tid.APP_CONFIG.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>Config");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppConfig.class.getName());
		r.setJetPath("/backend-appbase/AppConfig.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_CONTEXT() {
		Template r = new Template();
		r.setName(Tid.APP_CONTEXT.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>Context");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppContext.class.getName());
		r.setJetPath("/backend-appbase/AppContext.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_TABLES_TOOL() {
		Template r = new Template();
		r.setName(Tid.APP_TABLES_TOOL.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>TablesTool");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppTablesTool.class.getName());
		r.setJetPath("/backend-appbase/AppTablesTool.jet");
		r.setMergeStrategy(TemplateMergeStrategy.SKIP);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(null);
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_EXT_SERVICE_BASE() {
		Template r = new Template();
		r.setName(Tid.APP_EXT_SERVICE_BASE.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>ExtServiceBase");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppExtServiceBase.class.getName());
		r.setJetPath("/backend-appbase/AppExtServiceBase.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_TEST_SERVICE_BASE() {
		Template r = new Template();
		r.setName(Tid.APP_TEST_SERVICE_BASE.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>TestServiceBase");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppTestServiceBase.class.getName());
		r.setJetPath("/backend-appbase/AppTestServiceBase.jet");
		r.setMergeStrategy(TemplateMergeStrategy.SKIP);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_TEST_DAO_BASE() {
		Template r = new Template();
		r.setName(Tid.APP_TEST_DAO_BASE.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>TestDaoBase");
		r.setTargetDir("<%=Backend%>/<%=src-gen-test%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppTestDaoBase.class.getName());
		r.setJetPath("/backend-appbase/AppTestDaoBase.jet");
		r.setMergeStrategy(TemplateMergeStrategy.SKIP);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_DBS_PROVIDER() {
		Template r = new Template();
		r.setName(Tid.APP_DBS_PROVIDER.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>DbsProvider");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppDbsProviders.class.getName());
		r.setJetPath("/backend-appbase/AppDbsProviders.jet");
		r.setMergeStrategy(TemplateMergeStrategy.SKIP);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_TEST_STARTUP() {
		Template r = new Template();
		r.setName(Tid.APP_TEST_STARTUP.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>TestStartup");
		r.setTargetDir("<%=Backend%>/<%=src-gen-test%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.TestAppStartup.class.getName());
		r.setJetPath("/backend-appbase/TestAppStartup.jet");
		r.setMergeStrategy(TemplateMergeStrategy.SKIP);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_README() {
		Template r = new Template();
		r.setName(Tid.APP_README.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>-ReadMe");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".txt");
		r.setGeneratorFqn(backend.appbase.AppReadMe.class.getName());
		r.setJetPath("/backend-appbase/AppReadMe.jet");
		r.setMergeStrategy(TemplateMergeStrategy.OVERWRITE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {IServiceType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_PERSISTENCE_XML() {
		Template r = new Template();
		r.setName(Tid.APP_PERSISTENCE_XML.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("persistence");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".xml");
		r.setGeneratorFqn(backend.AppPersistenceXml.class.getName());
		r.setJetPath("/backend-appbase/AppPersistenceXml.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_SERVER() {
		Template r = new Template();
		r.setName(Tid.APP_SERVER.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("n.a.");
		r.setTargetDir("n.a.");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppServer.class.getName());
		r.setJetPath("/backend-appbase/AppServer.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(new Class<?> [] {ApplicationBaseType.class,});
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_JETTY_LAUNCHER() {
		Template r = new Template();
		r.setName(Tid.APP_JETTY_LAUNCHER.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>Launcher");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppJettyLauncher.class.getName());
		r.setJetPath("/backend-appbase/AppJettyLauncher.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(null);
		r.setRank(2);
		return r;
	}

	private ITemplate makeTemplate_APP_JETTY_SERVLETCONFIG() {
		Template r = new Template();
		r.setName(Tid.APP_JETTY_SERVLETCONFIG.name());
		r.setPackage("<%=App-package%>");
		r.setClassname("<%=App-name%>ServletConfig");
		r.setTargetDir("<%=Backend%>/<%=src-gen%>");
		r.setFileExtension(".java");
		r.setGeneratorFqn(backend.appbase.AppJettyServletConfig.class.getName());
		r.setJetPath("/backend-appbase/AppJettyServletConfig.jet");
		r.setMergeStrategy(TemplateMergeStrategy.JAVA_MERGE);
		r.setCartridgeName(CARTRIDGE_NAME);
		r.setApplyToClasses(null);
		r.setRank(2);
		return r;
	}


	public static ITemplate getTemplate(Tid aTid) {
		if (allTemplates == null) {
			new JavaConstants();
		}

		for (ITemplate t : allTemplates) {
			if (t.getName().equals(aTid.name())) {
				return t;
			}
		}
		return null;
	}
	
}
